<template>
  <div>
    <!-- 下单成功支付框 -->
    <PayBox ref="payBox" :noBackBtn="true"/>

    <div class="marginB10 f_16 c999 paddingL10">商标担保注册</div><B3 ref="B3" :orderInfo="orderInfo" />
    <div class="marginB10 f_16 c999 paddingL10">申请人信息</div><B2 ref="B2" />

    
      <div class="clearBoth" style="height:40px;"></div>
      
      <div class="diBs tran3 overflowH f_16 c888" :style="`left: ${$store.state.F_cat.collapsed?'64':'200'}px;`" style="line-height:45px;">
        <template v-if="!$app.judgeData(order_id)">
          <Button
            type="primary"
            class="relative marginR20"
            size="large"
            @click="tmGo"
          >
            <Icon
              type="md-checkmark-circle-outline"
              size="20"
              class="marginR5 relative"
            />提 交
          </Button>
          <!-- <Button
            type="default"
            class="relative marginR20"
            size="large"
            @click="$app.alert('草稿箱功能还没做','N天后再搞')"
          >
            草稿箱
          </Button> -->
        </template>
        
        <template v-else>

          <Button type="primary" size="large" class="marginR20" ghost @click="backOrSee">
            <Icon type="md-arrow-round-back" size="18" class="relative"  />返回
          </Button>
          <template v-if="$app.judgeData(bz_id)">
            <Button
              type="primary"
              class="relative marginR20"
              size="large"
              @click="tmGo"
            >提交补正</Button>
          </template>
          <template v-else>
            <Button
              type="primary"
              class="relative marginR20"
              size="large"
              @click="tmGo"
            >确认修改</Button>
          </template>
        </template>
      </div>
    
  </div>
</template>

<script>
import B2 from "./b2";
import B3 from "./db/b3";
import PayBox from "@$@/_service/payBox";
import info_edit_do from "@$@/js/$common/info_edit_do";
export default {
  name: "bigCom",//商标 担保注册流程
  components: { B2, B3, PayBox },
  data() {
    let {
      $route: {
        query: { type, order_id,id:bz_id }
      }
    } = this;
    let data = {
      type,
      order_id,
      bz_id,
      orderInfo: {} //商标详情，修改商标订单的时候用
    };
    return data;
  },
  created() {
    let { order_id } = this;
    if ($app.judgeData(order_id)) {
      
      //商标详情
      $ajax.tmInfo(order_id, resData => {
        this.orderInfo = resData;
        //商标全局赋值 修改订单专用
        info_edit_do.tmEditGlobe(this);
      });
    }
  },

  methods: {
    // 返回上一级
    backOrSee(){
      $app.backOrSee();
    },
    //点击提交
    tmGo() {
      let that = this;
      let { 
        order_id,bz_id
      } = that;

      //商标信息
      let {
        xTlex: type, //1文字，2图形，3文字及图形
        xPiw: upload_type, //1自动生成,2手动上传
        zName1, //商标名称 纯文字
        img_path: { file_path: img_path },
        remark, //商标说明
      } = this.$refs["B3"];

      let name = "";
      switch (parseInt(type)) {
        case 1:
          name = zName1;
          break;
        case 2:
          name = "";
          break;
        case 3:
          name = "";
          break;
      }

      console.log("商标信息 = ", type, upload_type);

      


      // console.log('文字 = ',name);
      // console.log('商标图片 = ',img_path);

      //B2 商标信息
      //企业9个字段
      //个体工商户11个字段
      let {
        reg_people_type, //申请人资质,1=企业,2=个体工商户
        reg_people_name, //公司名
        idcard,// 身份证
        business_license_number, //请输入统一社会信用代码 、 身份证
        business_license_path: { file_path: business_license_path },
        idcard_path: { file_path: idcard_path },

        business_license_province,//省份名称 中文汉字
        business_license_province_code,//省份代码
        business_license_city,//城市名称 中文汉字
        business_license_city_code,//城市代码
        business_license_detail_address,//地址(短地址)
        
        business_license_img_path: { file_path: business_license_img_path },
        idcard_img_path: { file_path: idcard_img_path },
        
        attorney_path: { file_path: attorney_path }
      } = this.$refs["B2"];

      //B3所选中的商标分类
      let { whoShow } = this.$refs["B3"];

      let zhiN_list='';

      if(whoShow==99){//补正提交
        zhiN_list=this.$refs["B3"].$refs["Z3"].cglist;// 赋值
      }else{//未付款之前的修改+首次提交

        //1 智能推荐 2自助选择 =》都是采用一样的数据结构
        let cglist='';
        if(whoShow==1){//1 智能推荐
          cglist = this.$refs["B3"].$refs["Z1"].cglist;
        }else{//2 自助选择
          cglist = this.$refs["B3"].$refs["Z2"].cglist;
        }

        zhiN_list=$app.z_XHuan(cglist);// 赋值

      }
      
      console.log("选中的商标分类 = ", zhiN_list);

      if (!$app.judgeData(zhiN_list)) {
        $app.alert("请选择商标分类");
      } else {
        let cg_list = [];
        zhiN_list.forEach((val, i) => {
          $app.editList_or_items(val).forEach((val, i) => {
            cg_list.push(val.fcgid);
          });
        });
        console.log("cg_list = ", $app.arrayToStr(cg_list));

        

        let obj = {
          goods_type:this.type,
          bz_id,//补正时候的id

          //订单ID，首次提交为空；有订单ID，就是修改订单；
          order_id: order_id,
          type, //1文字，2图形，3文字及图形
          upload_type:((type!=1)?2:upload_type), //1自动生成,2手动上传
          name, //商标名称 纯文字
          img_path:img_path, //商标图

          reg_people_type, //申请人资质,1=企业,2=个体工商户
          reg_people_name, //公司名
          idcard,//身份证
          business_license_number,//营业执照

          business_license_address:(business_license_province+business_license_city+business_license_detail_address), //长地址
          business_license_province,//省份名称 中文汉字
          business_license_province_code,//省份代码
          business_license_city,//城市名称 中文汉字
          business_license_city_code,//城市代码
          business_license_detail_address,//地址(短地址)
          
          remark, //商标说明
          business_license_path,
          idcard_path,
          idcard_img_path,
          business_license_img_path,
          attorney_path,
          cg_list
        };

        
        //统一 提交
        $app.tmSubmitZ(that,obj,order_id,bz_id);

      }
    }
  },
  mounted() {
    //
  }
};
</script>

